package com.study.cloud.simpleprovideruser.controller;

import com.study.cloud.simpleprovideruser.pojo.User;
import com.study.cloud.simpleprovideruser.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;

@RestController
// @EnableAutoConfiguration
public class UserController {

    @Autowired
    private UserService userService;

    @Value("${server.port}")
    private String port;

    @GetMapping("/simple/{id}") // 相当于requestMapping （value="xxx" method=get）
    public User findById(@PathVariable Long id) {
        System.out.println(port);

        return userService.findById(id);
    }

    @PostMapping("/user") // 相当于requestMapping （value="xxx" method=get）
    @ResponseBody
    public User postUser(@RequestBody User user) {
        return user;
    }
}
